
var template;

function initDataGrid()
{
	dataGrid.appendField(new DataGridField("",50,DataType.lineNumber));
	dataGrid.appendField(new DataGridField("Code",120));
	dataGrid.appendField(new DataGridField("Name",120));
	dataGrid.appendField(new DataGridField("Remark",200));
	dataGrid.selectedEvent=dataGridSelectedEvent;
	dataGrid.init(300);
}

function dataGridSelectedEvent(dataGrid,line,isSelected)
{
	if(dataGrid.selectedRows.length>0)
	{
		$("deleteButton").disabled=false;
		if(dataGrid.selectedRows.length==1)
		{
			$("modifyButton").disabled=false;
			return;
		}
	}
	else
	{
		$("deleteButton").disabled=true;
	}

	$("modifyButton").disabled=true;
}

function init()
{
	//用现有模板类实现大部分的操作
	template=new SimpleTemplate();
	template.actionClass=DictionaryConfigAction;
	template.dataGridListCtrl=dataGridListCtrl;
	template.editPart=editPart; 
	template.listFields=new Array("id","code","name","remark");
	template.validate=new ValidateConfig('dictionaryConfig.check.xml');

	template.init();
}

initEvents.push(initDataGrid);
initEvents.push(init);
